'use strict';
/**
 * @Controller news
 */
const Controller = require('egg').Controller;
const ModelName = 'News'
class NewsController extends Controller {
    /**
   * @Router POST /news/pages
   * @Request body number limit
   * @Request body number offset
   * @Summary 分页
   */
    async pages() {
        const { ctx } = this;
        const { limit = 20, offset=1 } = ctx.params
        const data = await ctx.service.sequelize.pages(ModelName,ctx.params)
        ctx.body = data;
    }
     /**
   * @Router POST /news/save
   * @Request body number limit
   * @Request body number offset
   * @Summary 保存
   */
    async save(){
        const { ctx } = this;
        const data =  await ctx.service.sequelize.insert(ModelName,ctx.params)
        ctx.body = data
    }
     /**
   * @Router GET /news/delete
   * @Request query number id
   * @Summary 删除
   */
    async delete(){
        const { ctx } = this;
        const data =  await ctx.service.sequelize.delete(ModelName,ctx.params)
        ctx.body = data
    }
     /**
   * @Router PUT /news/update
   * @Request body number limit
   * @Request body number offset
   * @Summary 更新
   */
    async update(){
        const { ctx } = this;
        const data =  await ctx.service.sequelize.update(ModelName,ctx.params)
        ctx.body = data
    }
     /**
   * @Router GET /news/list
   * @Request query number limit
   * @Description list
   * @Summary 列表
   */
    async list(){
        const { ctx } = this;
        const data =  await ctx.service.sequelize.list(ModelName,ctx.params)
        ctx.body = data
    }
}

module.exports = NewsController;
